This invention relates to a graphics processing apparatus and method and, more particularly, to a graphics drawing apparatus and method for drawing lines.
In order to draw a straight line, which is given by logical coordinate values, on a display device, it is necessary to execute processing whereby the area which the straight line, which is calculated from the logical coordinates, occupies on the physical coordinate system of the display device is determined in accordance with a fixed rule. This processing shall be referred to as "line drawing processing" below.
In order to draw a straight line having width in conventional line drawing processing, the method employed involves creating a polygonal pen corresponding to the width of the line and extracting a pen step that conforms to the required line width and line slope, whereby a thickness commensurate with the line width can be expressed regardless of the angle defined by the slope of the straight line.
1. Polygonal pen and related data structure
A polygonal pen partitions a quadrant having a radius the same as that of a line thickness W in accordance with a suitable partitioning rule and adopts a vector from a certain vertex to the neighboring vertex as a drawing element (hereinafter a "pen step"). The pen step corresponding to the width of one line starts from a horizontal step and ends with a vertical step (see FIG. 1).
Each pen step includes data comprising slope, direction from the center to the vertex and coordinates of the vertex. Each pen step possesses data in which these three values make up one set, and entries to all pen-step data are held sequentially from a line width of zero to a maximum line width.
Furthermore, an entry to a horizontal pen step and an entry to a vertical pen step are held in the form of a table in correspondence with each line width, and the necessary pen step of the line width is extracted by searching the table (see FIG. 3).
2. Drawing processing utilizing polygonal pen How a straight line of line width "2" is drawn will be described in simple terms with reference to FIGS. 1 and 2.
(1) A polygonal pen conforming to the width of the straight line to be drawn is created.
(2) As shown in FIG. 2, a pen step having a slope nearest to the vertical with respect to the slope of a straight line connecting two points A and B is selected from the pen table shown in FIG. 1 [the pen table created in (1) above].
(3) Since the pen having the vertex coordinates (1,-0.25) in FIG. 1 is the nearest in this example, RTop is found by adding (1,-0.25) to the coordinates of A and LTop is found by subtracting (1,-0.25) from the coordinates of A.
(4) Auxiliary lines having the same slopes as the straight lines are extended from RTop and LTop, and the intersections of these auxiliary lines with the base line of a scanning line are adopted as the x coordinates of a contour line at this scanning line. One of these coordinates is found for each of the two auxiliary lines having RTop and LTop as their starting points. Thus, one set of x coordinates is obtained for one scanning line. The portion lying between these x coordinates is made black.
(5) This processing is executed, with regard to every scanning line, from the starting point (A) to the end point (B) to obtain the contour line of the entire straight line.
With this drawing method utilizing the polygonal pen, a straight line is not thickened only in a fixed direction at all times with regard to horizontal lines. The method is so contrived that a straight line is drawn with substantially the same width regardless of the angle as well.
Basically this processing is executed once with regard to a straight line but is executed repeatedly with regard to each line segment in case of a polygon or polygonal line. Further, in the case of a curve or ellipse, the shape is partitioning into very small segments, a polygonal approximation is performed and the above-described processing-is executed.
In a case where a special shape is being used at the end point of a straight line or at the connection between two straight lines, the coordinates of the respective contour lines are determined by utilizing the polygonal pen.
In selecting the optional pen step for the slope of a straight line using the conventional method described above, it is necessary to execute processing in which sequentially arrayed pen steps are extracted one at a time and it is determined whether each is suitable or not. Further, coordinates of a contour line are determined for every scanning line based upon the pen-step information. Consequently, numerical calculations are numerous and processing takes times. Furthermore, since the number of pen steps possessed by the polygonal pen increases in dependence upon the line width, creating the polygonal pen takes time when line width is great, namely in the case of a thick line.
In the drawing of graphics using line segments as structural elements, there are instances where, depending upon the figure of the original graphic, problems relating to shape do not arise even when all processing is not executed in its entirety. Rather, there are instances where processing speed is a bigger problem than shape. This is the case for straight lines having a high frequency of use.
Executing drawing processing indiscriminately with regard to such line segments using the above-described technique is inefficient.
The technique described above is effective for shaping a straight line having a large width and an arbitrary angle. However, in a case where line width is sufficiently small in comparison with the pixel (dot) size of the display device, there is almost no effect in terms of dealing with angles finely. On the contrary, the adverse effects of error due to coordinate calculations become conspicuous and there is the possibility that the original shape will become unrecognizable.